package day_2022_4_to_7.day48;

/**
 * 跳台阶扩展问题
 * @author haomin
 * @date 2022/05/24 13:52
 **/
public class Day26_1_jumpFloorII {
    public static void main(String[] args) {
        System.out.println(jumpFloorII(3));
    }

    //  f(n-1) = f(0) + f(1)+f(2)+f(3) + ... + f((n-1)-1) = f(0) + f(1) + f(2) + f(3) + ... + f(n-2)
    //    f(n) = f(0) + f(1) + f(2) + f(3) + ... + f(n-2) + f(n-1) = f(n-1) + f(n-1)
    //    可以得出：
    //    f(n) = 2*f(n-1)

    public static int jumpFloorII (int number) {
        if(number <= 0){
            return  -1;
        }else if(number == 1){
            return 1;
        }else {
            return 2 * jumpFloorII(number-1);
        }
    }
}